'''
密码验证程序 retry 3次：验证一个文本里面的密码，如果正确返回，不正确重试3次
'''
def print_mone():
    print('='*50)
    print("请输入一个密码最多输入三次")
    print("输入q退出")
    print('='*50)
#打印功能菜单
print_mone()
i = 1
while i <= 3:
  with open('passwd.txt') as f:
     passwd = f.readlines()
  trun = input("请输入一个密码:")
  for line in passwd:
        passwd1 = line.strip('\n')
        if  trun == passwd1:
            print("密码正确")
        if i == 1:
          if trun != passwd1:
             print("密码不正确，请继续输入")
        if i == 2:
          if trun != passwd1:
             print("密码不正确，请继续输入")
        if i == 3:
           if trun != passwd1:
              print(" 输错三次程序退出")
  if trun == passwd1:
    break
  if trun == "q":
     break
  i +=1
